package org.jsrml.common.persistence.web;

import java.io.IOException;

import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

@Configuration
public class RedissonConfig implements InitializingBean{
	
	@Bean(destroyMethod = "shutdown",name="redissonClient")
    public RedissonClient redisson(@Value("classpath:config/spring-redisson.yaml") Resource configFile) throws IOException {
        Config config = Config.fromYAML(configFile.getInputStream());
        return Redisson.create(config);
    }

	/*@Bean
	public RedissonPool redissonPool(){
		return new RedissonPool("127.0.0.1", "6379");
	}*/
	
	@Override
	public void afterPropertiesSet() throws Exception {
		
	}
}
